-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate index file #46
Generate index file #46
Conversation
#!/usr/bin/env node | ||
|
||
const { docTitle } = require('../constants'); | ||
const chapterHelper = require('../src/helper/chapterHelper'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ processChapter } = require('../src/helper/chapterHelper');
|
||
const loadedOutline = jsyaml.safeLoad(readFileSync(`${__dirname}/../config/outline.yaml`, 'utf8')); | ||
|
||
const index = `# ${docTitle}\n\n${loadedOutline.map((chapter) => chapterHelper.processChapter(chapter, fileProcessor)).join('\n\n')}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chapterHelper.processChapter
=> processChapter
}, | ||
}; | ||
|
||
module.exports = chapterHelper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you use ES6 modules instead?
|
||
const index = `# ${docTitle}\n\n${loadedOutline.map((chapter) => chapterHelper.processChapter(chapter, fileProcessor)).join('\n\n')}`; | ||
|
||
writeFile(resolve(__dirname, '../src/pages/docs/index.md'), index, error => error && console.warn(error)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really necessary to generate a Markdown file? Can't we use directly the existing YAML file as a source for Gatsby?
https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-yaml
gatsbyjs/gatsby#3195
WIP (Cleaning).